package net.app.zoneland.system.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import net.app.zoneland.system.entity.SysUser;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @Description
 * @Author LENOVO
 * @CreateTime 2020/12/27 17:36
 * @Version: 1.0
 */
@Mapper
public interface SysUserDao extends BaseMapper<SysUser> {

    /**
     * 查询用户信息分页
     * @param page
     * @param user
     * @return
     */
    @Select("<script> " +
            "   select u.* from sys_user u " +
            "   where 1=1 " +
            " <if test ='user.username!=null and user.username.trim() neq \"\"'>" +
            "       and u.username like concat('%',#{user.username},'%')" +
            " </if>" +
            " <if test ='user.mobile!=null and user.mobile.trim() neq \"\"'>" +
            "       and u.mobile like concat('%',#{user.mobile},'%')" +
            " </if>" +
            " <if test ='user.status!=null and user.status>0'>" +
            "       and u.status = #{user.status}" +
            " </if>" +
            "</script>")
    List<SysUser> list(Page<SysUser> page, SysUser user);

}
